/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eit.ntc.lmsbackend.utils;

import com.eit.toschoolonline.lms.jdo.LearningItemM;
import javax.servlet.http.HttpServletRequest;
import org.springframework.webflow.context.servlet.ServletExternalContext;
import org.springframework.webflow.execution.RequestContext;

/**
 *
 * @author tawatchai
 */
public class RoleUtils {
    public static String getRole(HttpServletRequest request){
        String role = "";
        if (request.isUserInRole("NTC_ADMIN")){
            role = LearningItemM.NTC_ROLE;
        };
        if (request.isUserInRole("INFO_ADMIN")){
            role = LearningItemM.INFO_ROLE;
        };
        return role;
    }
      public static String getRole(RequestContext context){
        ServletExternalContext seContext =  (ServletExternalContext) context.getExternalContext();
        HttpServletRequest request = (HttpServletRequest) seContext.getRequest();
        return getRole(request);
    }
}
